package com.woniuxy.interceptor.config;
import com.woniuxy.interceptor.PermsInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.annotation.Resource;

/**
 * 该配置类用来注册拦截器
 * */
//@Configuration // 作为配置类
public class InterceptorConfig implements WebMvcConfigurer {

//    注入
    @Resource
    private PermsInterceptor permsInterceptor;

//    addInterceptors：添加拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        注册拦截器，并制定拦截请求的路径，这里是全部请求都拦截  "/**"
        registry.addInterceptor(permsInterceptor).addPathPatterns("/**");
    }
}
